<#include "./template/general_temp.ftl">

<#macro content>
<div class="row" xmlns:input="http://www.w3.org/1999/html" xmlns:input="http://www.w3.org/1999/html">
    <div class="box col-md-12">
        <div class="box-inner">
            <div class="box-header well" data-original-title="">
                <h2><i class="glyphicon glyphicon-edit"></i>编辑</h2>

                <div class="box-icon">
                    <a href="#" class="btn btn-setting btn-round btn-default"><i class="glyphicon glyphicon-cog"></i></a>
                    <a href="#" class="btn btn-minimize btn-round btn-default"><i class="glyphicon glyphicon-chevron-up"></i></a>
                    <a href="#" class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a>
                </div>
            </div>
            <div class="box-content">
                <@form.form modelAttribute="editEventCommand" role="form" enctype="multipart/form-data">
                    <@form.errors path='*' element="div" cssClass="alert alert-success" cssErrorClass="alert alert-danger"/>
                    <#if no_error??>
                        <div class="alert alert-success">
                            <strong>Well done! </strong>提交成功。
                        </div>
                    </#if>
                    <div class="form-group">
                        <label for="eventName">名称</label>
                        <@form.input path="eventName" cssClass="form-control" id="eventName" placeholder="请输入活动名称"/>
                    </div>
                    <div class="form-group">
                        <label for="zhubanfang">主办方</label>
                        <@form.input path="eventZhubanfang" cssClass="form-control" id="zhubanfang" placeholder="请输入活动主办方"/>
                    </div>
                    <div class="form-group">
                        <label for="eventLocation">地址</label>
                        <@form.input cssClass="form-control" path="eventLocation" id="eventLocation" placeholder="请输入地址"/>
                    </div>
                    <div class="form-group box col-md-12">
                        <div class="col-md-4">
                            <label for="zhubanfang">开始时间</label>
                            <input name="eventStartTime" id="eventStartTime" value="${editEventCommand.eventStartTime!}" type="text" class="form-control form_datetime" size="16" readonly/>
                        </div>
                        <div class="col-md-4">
                            <label for="eventEndTime">结束时间</label>
                            <input name="eventEndTime" id="eventEndTime" value="${editEventCommand.eventEndTime!}" type="text" class="form-control form_datetime" size="16" readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="eventQianyan">前言</label>
                        <@form.textarea path="eventQianyan" id="eventQianyan" ></@form.textarea>
                    </div>
                    <div class="form-group">
                        <label for="eventProcess">流程</label>
                        <@form.textarea path="eventProcess" id="eventProcess" ></@form.textarea>
                    </div>
                    <div class="form-group">
                        <label for="eventInvited">拟邀嘉宾</label>
                        <@form.textarea path="eventInvited" id="eventInvited" ></@form.textarea>
                    </div>
                    <div class="form-group">
                        <label for="eventLinks">合作伙伴</label>
                        <@form.textarea path="eventLinks" id="eventLinks" ></@form.textarea>
                    </div>
                    <div class="form-group">
                        <label for="eventDesc">联系方式</label>
                        <@form.textarea path="eventDesc" id="eventDesc" ></@form.textarea>
                    </div>
                    <div class="form-group" id="eventBigImgBlock">
                        <@form.hidden path="eventBigImg" id="eventBigImg"/>
                        <#if editEventCommand.eventBigImg??>
                            <img style='width:200px;' src='${base}/system/getImg?imgId=${editEventCommand.eventBigImg}'/>
                        </#if>
                    </div>
                    <div class="form-group">
                        <label for="eventBigImgSel">主图</label>
                        <input data-no-uniform="true" type="file" id="eventBigImgSel" class="file_upload">
                    </div>
                    <div class="form-group" id="eventThumImgBlock">
                        <@form.hidden path="eventThumImg" id="eventThumImg"/>
                        <#if editEventCommand.eventThumImg??>
                            <img style='width:200px;' src='${base}/system/getImg?imgId=${editEventCommand.eventThumImg}'/>
                        </#if>
                    </div>
                    <div class="form-group">
                        <label for="eventThumImgSel">缩略图</label>
                        <input data-no-uniform="true" type="file" id="eventThumImgSel" class="file_upload">
                    </div>
                    <div class="form-group">
                        <label for="eventSlug">关键词</label>
                        <@form.input path='eventSlug' id="eventSlug" cssClass="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="status">状态</label>
                        <@form.radiobutton path="eventStatus" value="1" checked="checked"/>正在进行中
                        <@form.radiobutton path="eventStatus" value="2"/>已结束
                    </div>
                    <button type="submit" class="btn btn-default">提交</button>
                </@form.form>
            </div>
        </div>
    </div>
    <!--/span-->
</div>
<!--/row-->
</#macro>

<#macro script>
<script type="text/javascript">
    UE.getEditor('eventQianyan');
    UE.getEditor('eventProcess');
    UE.getEditor('eventInvited');
    UE.getEditor('eventLinks');
    UE.getEditor('eventDesc');


    //uploadify - multiple uploads
    $('#eventBigImgSel').uploadify({
        'swf': '${base}/system/charisma-static/misc/uploadify.swf',
        'uploader': '${base}/system/uploadImg',
        'fileTypeExts': '*.jpg;*.gif;*.jpeg;*.png;',
        'buttonText' : '请选择图片',
        'fileObjName':'file',
        'multi': false,
        onSelect : function(file) {//当每个文件添加至队列后触发
            if(file.size >= 2 * 1024 * 1024){
                alert("选择文件不能超过2MB");
                return false;
            }
        },
        onError: function(event, queueID, fileObj) {
            alert("文件:" + fileObj.name + "上传失败");
        },
        onUploadSuccess: function(file,data,response){
            data = JSON.parse(data);
            $("#eventBigImgBlock img").remove();
            $("#eventBigImgBlock").append("<img style='width:200px;' src='${base}/system/getImg?imgId=" + data.filePath + "'/>");
            $("#eventBigImg").val(data.filePath);
        }
        // Put your options here
    });
    $('#eventThumImgSel').uploadify({
        'swf': '${base}/system/charisma-static/misc/uploadify.swf',
        'uploader': '${base}/system/uploadImg',
        'fileTypeExts': '*.jpg;*.gif;*.jpeg;*.png;',
        'buttonText' : '请选择图片',
        'fileObjName':'file',
        'multi': false,
        onSelect : function(file) {//当每个文件添加至队列后触发
            if(file.size >= 2 * 1024 * 1024){
                alert("选择文件不能超过2MB");
                return false;
            }
        },
        onError: function(event, queueID, fileObj) {
            alert("文件:" + fileObj.name + "上传失败");
        },
        onUploadSuccess: function(file,data,response){
            data = JSON.parse(data);
            $("#eventThumImgBlock img").remove();
            $("#eventThumImgBlock").append("<img style='width:200px;' src='${base}/system/getImg?imgId=" + data.filePath + "'/>");
            $("#eventThumImg").val(data.filePath);
        }
    });
</script>
</#macro>
